package com.polaris.live.utils.sensor.impl

import androidx.appcompat.app.AppCompatActivity
import com.polaris.live.utils.sensor.SensorModuleHelper
import com.polaris.live.utils.sensor.base.DialogModule
import com.polaris.live.utils.sensor.base.IModule
import com.polaris.live.utils.sensor.module.FunctionToolsModule
import com.polaris.live.utils.sensor.module.PageToolsModule
import com.polaris.live.utils.sensor.module.WebToolsModule

/**
 * 测试模块帮助类
 *
 * @author Created by lucas on 2023/10/26 19:44
 * @since 1.0.0
 */
class ToolsModuleHelper(
    context: AppCompatActivity
) : SensorModuleHelper(context) {

    override fun showSetting(): Boolean {
        val module = object : DialogModule(mContext) {

            override val title: String = "Universal Tools"

            override fun createModules(): Array<IModule> = arrayOf(
                WebToolsModule(mContext),
                PageToolsModule(mContext),
                FunctionToolsModule(mContext)
            )
        }
        module.setOnDismissListener { mIsShowed = false }
        module.runModule()

        return module.isShowDialog()
    }

    companion object {

        fun attach(context: AppCompatActivity): ToolsModuleHelper {
            return ToolsModuleHelper(context)
        }
    }
}